home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0050_Get RIGHT part of STRING.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  1KB  |  43 lines

  1. {*****************************************************************************
  2.  * Function ...... Right()
  3.  * Purpose ....... To return the right part of a string
  4.  * Parameters .... s         String to return the right part of
  5.  *                 n         Number of characters to return
  6.  * Returns ....... A string containing the <n> rightmost characters of <n>.
  7.  * Notes ......... None
  8.  * Author ........ Martin Richardson
  9.  * Date .......... October 2, 1992
  10.  *****************************************************************************}
  11. FUNCTION Right( s: STRING; n: BYTE ): STRING; ASSEMBLER;
  12. ASM
  13.       PUSH    DS
  14.       LES     DI, @Result
  15.  
  16.       LDS     SI, s
  17.       MOV     AL, n
  18.       CLD
  19.       XOR     CX, CX
  20.  
  21.       MOV     CL, BYTE PTR [SI]
  22.       INC     SI
  23.       CMP     CX, 0
  24.       JZ      @@2
  25.       CMP     AL, 0
  26.       JLE     @@1
  27.  
  28.       MOV    BYTE PTR ES:[DI], AL
  29.       INC    DI
  30.  
  31.       SUB    CL, AL
  32.       ADD    SI, CX
  33.       MOV    CL, AL
  34.  
  35.       REP    MOVSB
  36.       JMP    @@3
  37.  
  38. @@1:  MOV     CL, 0
  39. @@2:  MOV     BYTE PTR ES:[DI], CL
  40. @@3:  POP     DS
  41. END;
  42.  
  43.